<?php 
// this file and function checked admin session value stored or not
require_once '../model/testimonials.php';
require_once '../model/users.php';
require_once '../includes/classes/pagination_class.php';	

// create object
$testimonialObj = new Model_Testimonial();
$user           = new Model_Users(); 

// GET VARIABLES WITH SORT , PAGE ,ORDER BY   VARIABLE   WHICH ARE 
	// HIDDEN VARIABLES
    
	$page = $_GET['page'];
	$id   = base64_decode($_GET['id']); 
	$user_id = base64_decode($_GET['uid']); 
	
// if all values are correct while updating or editing the testimonial	
if(isset($_POST['edittestimonial_btn']) &&  $_POST['username']!='' &&$_POST['description']!=''){
	
	$updateTestimonial                = array();
	$updateTestimonial['user_id']     = $_POST['username'];
/*	$updateTestimonial['title']       = $_POST['title'];*/
	$updateTestimonial['description'] = html_entity_decode(addslashes($_POST['description']));
	$updateTestimonial['added_date']  = date("Y-m-d H:m:s");	
	$testimonialObj->edit_Testimonial($updateTestimonial,$id);
	$_SESSION['msg']="<div class='success_msg'><span>Testimonial updated successfully!</span></div>";
	header('location:'.SITE_URL.'/admin/home.php?q=testimonials&page='.$page);
	exit;
}
	
	
	
	// CALL MODAL  HERE TO DETAIL news
	$details	 = $testimonialObj->list_TestimonialDetailsById($id);
//	echo "<pre>;".print_r($details);exit;
	$smarty->assign('testimonialDetails',$details);
	
	//specific user details 
	$specificUser = $user->getUserDetailsByUserId($user_id);
	$smarty->assign('userDetails',$specificUser);
	
	$userDetails = $user->getAllUsers($search, $limit='',$offset='');
	//echo"<pre>";print_r($userDetails);
	$smarty->assign("userArray",$userDetails); 

	
	
	## Set active class variable for left menu  (main menu and sub menu)
$smarty->assign('activeclass', 'testimonial');
$smarty->assign('mainmenu', '3');

$smarty->display(TEMPLATEDIR_ADMIN . 'testimonials/testimonial_edit.tpl');
unset($smarty);

?>